package com.icinfo.cloud.provider.punish.ucase.casemain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：非诉审核类型枚举
 *
 * @author xiangyuyu
 * @date 2022-04-09 14:21
 */
@AllArgsConstructor
public enum AdrApprovalTypeEnum {
    /**
     * 非诉审核类型枚举
     */

    A_01("01", "计生"),
    A_02("02", "国土"),
    A_03("03", "环保"),
    A_04("04", "工商"),
    A_05("05", "交通"),
    A_06("06", "劳动"),
    A_07("07", "水利"),
    A_08("08", "规划"),
    A_09("09", "综合执法局"),
    A_10("10", "人民政府"),
    A_11("11", "卫生"),
    A_12("12", "教育"),
    A_13("13", "安监"),
    A_14("14", "质监"),
    A_15("15", "公安"),
    A_16("16", "文化"),
    A_17("17", "海关"),
    A_18("18", "物价"),
    A_19("19", "税务"),
    A_20("20", "农业"),
    A_21("21", "其他");


    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (AdrApprovalTypeEnum e : AdrApprovalTypeEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return code;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (AdrApprovalTypeEnum e : AdrApprovalTypeEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
